package com.sbio.udiapp.adapter;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.sbio.udiapp.R;
import com.sbio.udiapp.listener.ListViewAdapterListener;

public class ViewHolder1<T extends ListItemData>  extends RecyclerView.ViewHolder{

    TextView tv;
    Button btn;

    public ViewHolder1(@NonNull View itemView) {
        super(itemView);
        tv = itemView.findViewById(R.id.tv_box_code);
        btn = itemView.findViewById(R.id.btn);
    }

    // 修改 bind 方法接收 ListItemData 类型
    public void bind(T data, ListViewAdapterListener<T> listener) {
        tv.setText(data.getDisplayText());
        btn.setOnClickListener(v -> listener.btn(data));
    }
}
